<template>
  <view class="container">
    <view class="example">
      <uni-forms ref="form" :model="device" labelWidth="80px">
        <uni-forms-item label="报工机" name="reportCode" required>
          <uni-easyinput v-model="device.reportCode" placeholder="请输入报工机编号" />
        </uni-forms-item>
        <uni-forms-item label="工位" name="workStation" required>
          <uni-easyinput v-model="device.workStation" placeholder="请输入工位" />
        </uni-forms-item>
      </uni-forms>
      <button type="primary" @click="submit">提交</button>
    </view>
  </view>
</template>
<script>
import UniForms from "../../../uni_modules/uni-forms/components/uni-forms/uni-forms.vue";
import UniEasyinput from "../../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.vue";
import UniFormsItem from "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.vue";

export default {
  components: {UniForms, UniEasyinput, UniFormsItem},
  data() {
    return {
      device: {
        reportCode: null,
        workStation: null,
      }
    }
  },
  onLoad() {
    this.device.reportCode = uni.getStorageSync('reportCode');
    this.device.workStation = uni.getStorageSync('workStation');
    if (uni.getStorageSync('interfaceUrl') !== null && uni.getStorageSync('interfaceUrl') !== '') {
      this.device.interfaceUrl = uni.getStorageSync('interfaceUrl');
    }

  },
  methods: {
    submit() {
      uni.setStorageSync('reportCode', this.device.reportCode);
      uni.setStorageSync('workStation', this.device.workStation);
      if (this.device.interfaceUrl !== null && this.device.interfaceUrl !== '') {
        uni.setStorageSync('interfaceUrl', this.device.interfaceUrl);
      }
      this.$modal.msgSuccess("保存成功")
    }
  }

}

</script>